Method of performing a simon&#39;s or a shor&#39;s quantum algorithm and relative quantum gate

ABSTRACT

A method for performing a Simon&#39;s or Shor&#39;s quantum algorithm over a function encoded with n qubits is provided. The method includes performing a superposition operation over a set of input vectors for generating a superposition vector, performing an entanglement operation for generating a corresponding entanglement vector, and performing an interference operation for generating a corresponding output vector. The superposition operation is carried out in a comparably fast manner by generating the superposition vector by identifying the non-null components thereof and by calculating, as a function of the n qubits, the value ½ n/2  of all the non-null components of the superposition vector, and by calculating indices of these components according to an arithmetic succession. The seed of this calculation is 1 and the common difference is 2 n . The method may be implemented in a quantum gate.

FIELD OF THE INVENTION

[0001] The present invention relates in general to quantum algorithms,and in particular, to a method and a corresponding quantum gate forperforming Simon's and Shor's algorithms without the need for storingvery large matrices.

BACKGROUND OF THE INVENTION

[0002] Quantum algorithms are global random searching algorithms basedon the principles, laws and quantum effects of quantum mechanics. Theyare used for controlling a process or for processing data in a database.They are particularly useful in performing intelligent processes ofsearch-of-minima intelligent operations.

[0003] In quantum search operations, each design variable is representedby a finite linear superposition of classical initial states. Through asequence of elementary unitary steps the initial quantum state |i> (forthe input) is manipulated in such a way that a measurement of the finalstate of the system yields the correct output. Usually, in the quantumsearch algorithm three principal operators are used, namely: linearsuperposition (coherent states), entanglement, and interference.

[0004] For a better understanding of the field of application of theinvention, a brief description of quantum search algorithms is provided.

[0005] A Survey of Quantum Algorithms:

[0006] The problems solved by quantum algorithms may be stated asfollows: Input A function f: {0, 1}^(n) → {0, 1}^(m) Problem Find acertain property of f

[0007] The structure of a quantum algorithm is outlined, in a high levelrepresentation, by the diagram of FIG. 1.

[0008] The input of a quantum algorithm is always a BOX 1: UNITARYMATRIX U_(F) A squared matrix U_(F) on the complex field is unitary ifits inverse matrix coincides with its conjugate transpose:       U_(F)⁻¹ = U_(F) ^(†) A unitary matrix is always reversible and preserves thenorm of vectors.

[0009] function f of a binary string into a binary string. This functionis represented as a map table, defining for each string its image. Thefunction f is first encoded into a unitary matrix operator U_(F)depending on the f properties. This operator calculates f when its inputand output strings are encoded into canonical base vectors of a complexHilbert space: U_(F) maps the vector code of every string into thevector code of its image by f.

[0010] Once the matrix operator U_(F) has been generated, it is embeddedinto a quantum gate G. The quantum gate G is a unitary matrix whosestructure depends on the form of the matrix U_(F) and on the problem tobe solved. The quantum gate is the core of a quantum algorithm. In everyquantum algorithm, the quantum gate acts on the initial canonical baseof vectors (a same vector may always be chosen) to generate a complexlinear combination (superposition) of base vectors as output. Thissuperposition contains all the information to answer the initialproblem.

[0011] After having made such a superposition, a measurement is done toextract this information. In quantum mechanics, a measurement is anon-deterministic operation that produces as output only one of the basevectors of the operation of superposition. The probability of each basevector being the output of the measurement depends on its complexcoefficient (probability amplitude) of entering in the complex linearcombination.

[0012] Each single operation of the quantum gate and the measurementform a quantum block. The quantum block is repeated k times to produce acollection of k base vectors. Since the measurement is anon-deterministic operation, these basic vectors will not necessarily beidentical and each one of them encodes the information needed to solvethe problem. The last part of the algorithm includes the interpretationof the collected base vectors to obtain with a certain probability theright answer to the initial problem.

[0013] Encoder:

[0014] The behavior of the encoder block is described in the detailedschematic diagram of FIG. 2. Function f is encoded into matrix U_(F) inthree steps.

[0015] Step 1:

[0016] The map table of function f:{0, 1}^(n)→{0, 1}^(m) is transformedinto the map table of the injective function F:{0, 1}^(n+m)→{0, 1}^(n+m)such that:

F(x ₀ , . . . , x _(n−1) , y ₀ , . . . , y _(m−1))=(x ₀ , . . . , x_(n−1) , f(x ₀ , . . . , x _(n−1))⊕(y ₀ , . . . , y _(m−1)))   (1) BOX2: XOR OPERATOR ⊕ The XOR operator between two binary strings p and q oflength m is a string s of length m such that the i-th digit of s iscalculated as the exclusive OR between the i-th digits of p and q:      p=(p₀, . . . , p_(n−1))       q=(q₀, . . . , q_(n−1)) s = p ⊕ q =((p₀ + q₀) mod 2, . . . , (p_(n−1) + q_(n−1)) mod 2)

[0017] The need to deal with an injective function comes from therequirement that U_(F) be unitary. A unitary operator is reversible, soit cannot map two different inputs to the same output. Given that U_(F)is the matrix representation of F, F must be infective. Should thematrix representation of function f be used, a non-unitary matrix mayresult, since f could be non-injective. Therefore, injectivity isassured by increasing the number of bits and by considering the functionF instead of the function f. Anyway, function f can always be calculatedfrom F by putting (y₀, . . . , y_(m−1))=(0, . . . , 0) in the inputstring and reading the last m values of the output string.

[0018] Step 2:

[0019] The map table of function F is transformed into map table U_(F),according to the following formula:

∀sε{0, 1}^(n+m) :U _(F)[τ(s)]=τ[F(s)]  (2)

[0020] The coding map τ:{0, 1}^(n+m)→c² ^(n+m) (c² ^(n+m) is the targetcomplex Hilbert space) is such that: $\begin{matrix}{{{\tau (0)} = {\begin{pmatrix}1 \\0\end{pmatrix} = {{{0\rangle}\quad {\tau (1)}} = {\begin{pmatrix}1 \\0\end{pmatrix} = {1\rangle}}}}}\quad {{\tau ( {x_{0},\ldots \quad,x_{n + m - 1}} )} = {{{\tau ( x_{0} )} \otimes \ldots \otimes {\tau ( x_{n + m - 1} )}} = {{x_{0}\quad \ldots \quad x_{n + m - 1}}\rangle}}}} & (3)\end{matrix}$

BOX  3:  VECTOR  TENSOR  PRODUCT  ⊗

The tensor product between two vectors of dimensions h and k is a tensorproduct of dimension h · k, such that:${{{{x\rangle} \otimes}y}\rangle} = {{\begin{pmatrix}x_{1} \\\cdots \\x_{h}\end{pmatrix} \otimes \begin{pmatrix}y_{1} \\\cdots \\y_{k}\end{pmatrix}} = {\begin{pmatrix}{x_{1}y_{1}} \\\cdots \\{x_{1}y_{k}} \\\cdots \\{x_{h}y_{1}} \\\cdots \\{x_{h}y_{k}}\end{pmatrix}\begin{matrix}\underset{\_}{{Physical}\quad {{interpretation}:}} \\\text{If a~~component of a complexvector is interpreted as theprobability amplitude of a systembeing in a given state (indexedby the component number), thetensor product between two vectors described the joint probability amplitude of twosystems being in a joing state.}\end{matrix}}}$

EXAMPLES: VECTOR TENSOR PRODUCTS

[0021] $\quad\begin{matrix}{{{{( {0\text{,}0} )\overset{\tau}{}\begin{pmatrix}1 \\0\end{pmatrix}} \otimes \begin{pmatrix}1 \\0\end{pmatrix}} = {\begin{pmatrix}1 \\0 \\0 \\0\end{pmatrix} = {00\rangle}}}} & {{{( {0\text{,}1} )\overset{\tau}{}\begin{pmatrix}1 \\0\end{pmatrix}} \otimes \begin{pmatrix}0 \\1\end{pmatrix}} = {\begin{pmatrix}0 \\1 \\0 \\0\end{pmatrix} = {01\rangle}}} \\{{{( {1\text{,}0} )\overset{\tau}{}\begin{pmatrix}0 \\1\end{pmatrix}} \otimes \begin{pmatrix}1 \\0\end{pmatrix}} = {\begin{pmatrix}0 \\0 \\1 \\0\end{pmatrix} = {10\rangle}}} & {{{( {1\text{,}1} )\overset{\tau}{}\begin{pmatrix}0 \\1\end{pmatrix}} \otimes \begin{pmatrix}0 \\1\end{pmatrix}} = {\begin{pmatrix}0 \\0 \\0 \\1\end{pmatrix} = {11\rangle}}}\end{matrix}$

[0022] Code τ maps bit values into complex vectors of dimension 2belonging to the canonical base of c². Moreover, using tensor products,τ maps the general state of a binary string of dimension n into a vectorof dimension 2^(n), and reducing this state to the joint state of the nbits forms the register. Every bit state is transformed into thecorresponding 2-dimension base vector and then the string state ismapped into the corresponding 2^(n)-dimension base vector by composingall bit-vectors through tensor products. In this sense, a tensor productis the vector counterpart of state conjunction.

[0023] Base vectors are denoted using the ket notation |i>. Thisnotation is taken from Dirac's description of quantum mechanics.

[0024] Step 3:

[0025] The map table of U_(F) is transformed into the matrix U_(F) byusing the following transformation rule:

[U _(F)]_(ij)=1

U _(F) j>=|i>  (4)

[0026] which can be easily understood by considering the vectors |i> and|j> as column vectors. Because these vectors belong to the canonicalbase, U_(F) defines a permutation map of the rows of the identitymatrix. In general, row |j> is mapped into row |i>. This rule will beillustrated more in detail in a sample quantum algorithm, namely theShor's algorithm.

[0027] Quantum Block:

[0028] The core of the quantum block is the quantum gate, which dependson the properties of the matrix U_(F). The scheme of FIG. 3 gives a moredetailed description of the quantum block. In FIG. 3, the matrixoperator U_(F) is the output of the encoder block represented in FIG. 2.Here, it becomes the input for the quantum block.

[0029] This matrix operator is first embedded into a more complex gate:the quantum gate G. Unitary matrix G is applied k times to an initialcanonical base vector |i> of dimension 2^(n+m). Every time, theresulting complex superposition G|0 . . 01 . . 1> of base vectors ismeasured, producing as a result one base vector |x_(i)>. All themeasured base vectors {|x₁>, . . , |x_(k)>} are collected together. Thiscollection is the output of the quantum block.

[0030] The intelligence of such algorithms rests in the ability to builda quantum gate that is able to extract the information necessary to findthe required property of f and to store it into the output vectorcollection. The structure of the quantum gate for every quantumalgorithm will be discussed in detail, observing that a generaldescription is possible. To represent quantum gates some specialdiagrams called quantum circuits will be used.

[0031] An example of a quantum circuit, relative to the so calledDeutsch-Jozsa's quantum algorithm, is illustrated in FIG. 4. Everyrectangle is associated to a matrix 2^(n)×2^(n), where n is the numberof lines entering and leaving the rectangle. For example, the rectanglemarked U_(F) is associated to the matrix U_(F). Typically, matrix Hrepresents a Hadamard rotation: $\begin{matrix}{H = {\frac{1}{\sqrt{2}}\begin{bmatrix}1 & {\quad 1} \\1 & {- 1}\end{bmatrix}}} & (5)\end{matrix}$

[0032] Quantum circuits provide a high-level description of the gate,and by using some transformation rules that are listed in FIGS. 5a to 5f, it is possible to compile them into the corresponding gate-matrix.BOX  4:  MATRIX  TENSOR  PRODUCT  ⊗

The tensor product between two matrices X_(n×m) and Y_(h×k) is a (block)matrix (n · h) × (m · k) such that: ${{X \otimes Y} = {{\begin{bmatrix}{x_{11}Y} & \ldots & {x_{1m}Y} \\\ldots & \ldots & \ldots \\{x_{n1}Y} & \ldots & {x_{nm}Y}\end{bmatrix}\quad {with}\quad X} = \begin{bmatrix}x_{11} & \ldots & x_{1m} \\\ldots & \ldots & \ldots \\x_{n1} & \ldots & x_{nm}\end{bmatrix}}}\quad$

EXAMPLE: MATRIX TENSOR PRODUCT

[0033] ${\begin{bmatrix}1 & 2 \\3 & 4\end{bmatrix} \otimes \begin{bmatrix}5 & 6 \\7 & 8\end{bmatrix}} = {\lbrack {\begin{matrix}{1.\begin{bmatrix}5 & 6 \\7 & 8\end{bmatrix}} \\{3.\begin{bmatrix}5 & 6 \\7 & 8\end{bmatrix}}\end{matrix}\quad \begin{matrix}{2.\begin{bmatrix}5 & 6 \\7 & 8\end{bmatrix}} \\{4.\begin{bmatrix}5 & 6 \\7 & 8\end{bmatrix}}\end{matrix}} \rbrack = \begin{bmatrix}5 & 6 & 10 & 12 \\7 & 8 & 14 & 16 \\15 & 18 & 20 & 24 \\21 & 24 & 28 & 32\end{bmatrix}}$

[0034] The manner of using these rules will become clearer when a firstsample of a quantum algorithm will be illustrated.

[0035] Decoder:

[0036] The decoder block has the function of interpreting the basevectors collected after the iterated execution of the quantum block.Decoding these vectors means to retranslate them back into binarystrings and interpreting them directly if they already contain theanswer to the starting problem. Alternatively, they may be used ascoefficient vectors for some system of equations to obtain the soughtsolution. This part will not be discussed in detail because it isrelatively straightforward.

[0037] To better illustrate a field of application of the invention, abrief description of the Shor's algorithm is given.

[0038] Shor's Algorithm:

[0039] Shor's problem is so stated:

[0040] Given an integer number N, find a factor p for N.

[0041] This problem seems to be different from the other problems solvedby quantum algorithms, but it can be reduced to an equivalent problemwith the same form as the other quantum problems. This reduction is madepossible by a result of the theory of numbers that relates the period rof a special periodic function to the factors of an integer N. Thisfunction is:

ƒ_(N,a):

→

such that ƒ_(N,a)(x)=a ^(x)modN

[0042] where a is a random number coprime to N, namely:

gcd(a, N)=1

where gcd(x, y) is the greatest common divisor between x and y.

[0043] This function is periodic (the period is at most N). Let theperiod be r. Then:

ƒ_(N,a)(0)=ƒ_(N,a)(r) a ^(r)≡1modN

[0044] If the period is even, this equation can be rewritten as:

(a^(r/2))²≡1modN

(a^(r/2))²1≡0modN

(a^(r/2)−1)(a^(r/2)+1)≡0modN

[0045] This means:

∃hε

:(a ^(r/2)−1)(a ^(r/2)+1)=hN

[0046] So, unless (a^(r/2)−1)≡0modN or (a^(r/2)+1)≡0modN, namelya^(r/2)≡±1modN, at least one of a^(r/2)+1 or a^(r/2)−1 must have anon-trivial factor in common with N. It may be found by calculation:

gcd(a^(r/2)−1,N) gcd(a^(r/2)+1,N).

[0047] Using this reduction, the true question becomes: “What is theperiod of f?” Since the period of this function is less than N, it maybe restricted to the interval [0, 1, . . . , N−1]. Every input value iscoded as a binary string. A number of bits n=[log N] (eventually [logN]+1) is needed to code all the N possible input values.

[0048] Therefore, Shor's problem is translated into the followingstandard quantum problem: Input f: {0, 1}^(n) → {0, 1}^(n) with period rProblem Find r

[0049] Encoder:

[0050] First a simple example will be dealt with, then conclusions willbe generalized.

[0051] A. Introductory example:

[0052] Consider the case:

N=4

n=2; a=3

[0053] Then, map table f is: TABLE 1 (x₀, x₁) f(x₀, x₁) 00 01 01 11 1001 11 11

[0054] The period of this function is r=2.

[0055] Step 1:

[0056] Function f is encoded into the injective function F built usingeq. (2). Therefore, the map table of F is as follows: TABLE 2 (x₀, . . ., x_(n−1), y₀, . . . , y_(n−1)) F(x₀, . . . , x_(n−1), y₀, . . . ,y_(n−1)) 0000 0001 0100 0111 1000 1001 1100 1111 0001 0000 0101 01101001 1000 1101 1110 0010 0011 0110 0101 1010 1011 1110 1101 0011 00100111 0100 1011 1010 1111 1100

[0057] Step 2:

[0058] The function F is encoded into the map table of the operatorU_(F): TABLE 3 |x₀ . . . x_(n−1) y₀ . . . y_(n−1)> U_(F)|x₀ . . .x_(n−1) y₀ . . . y_(n−1)> |0000> |0001> |0100> |0111> |1000> |1001>|1100> |1111> |0001> |0000> |0101> |0110> |1001> |1000> |1101> |1110>|0010> |0011> |0110> |0101> |1010> |1011> |1110> |1101> |0011> |0010>|0111> |0100> |1011> |1010> |1111> |1100>

[0059] Step 3:

[0060] The matrix corresponding to U_(F) is obtained by using the rule:

[U _(F)]_(ij)=1

U _(F) |j>=|i>

[0061] or in other words by observing that the first two vectors in theinput tensor product are left unchanged, whereas the operator acting onthe last two is chosen inside the set {I{circle over (x)}I, I{circleover (x)}C, C{circle over (x)}I, C{circle over (x)}C} wherein I is theidentity matrix and C is the complement matrix, depending on the valuesof the first two vectors: TABLE 4 U_(F) |00> |01> |10> |11> |00> I

C 0 0 0 |01> 0 C

C 0 0 |10> 0 0 I

C 0 |11> 0 0 0 C

C

[0062] This matrix preserves the first two vectors and it preserves thethird vector, flipping the fourth vector when the second vector is |0>;and flipping the third and fourth vectors when the second vector is |1>.

[0063] It is worth noting that the block matrix in cell (i, i) isidentical to the block matrix in cell ((i+r)modN, (i+r)modN) where i isthe binary label of the vector marking the matrix row and column of thecell.

[0064] B. Case with n=2:

[0065] In general, if n=2, a different value will be taken and so adifferent period r will be obtained, and the operator still maps thefirst n vectors into themselves but the block matrix pattern on the maindiagonal changes.

[0066] The matrix U_(F) has the following form: TABLE 5 U_(F) |00> |01>|10> |11> |00> M₀₀ 0 0 0 |01> 0 M₀₁ 0 0 |10> 0 0 M₁₀ 0 |11> 0 0 0 M₁₁

[0067] where M_(i)ε{I{circle over (x)}I, I{circle over (x)}C, C{circleover (x)}I, C{circle over (x)}C} and M_(i)=M_(j)

((j=i) OR (j=(i+r)modN)) .

[0068] C. General Case:

[0069] Through a similar reasoning the following general form for thematrix U_(F) when n>0 may be proposed: TABLE 6 U_(F) |0 . . . 0> |0 . .. 1> . . . |1 . . . 1> |0 . . . 0> M₀ . . . 0 0 . . . 0 |0 . . . 1> 0 M₀. . . 1 . . . 0 . . . . . . . . . . . . . . . |1 . . . 1> 0 0 0 M₁ . . .1

[0070] where M_(i)=P₁{circle over (x)} . . {circle over (x)}P_(n),P_(k)ε{I, C}, k=1, . . , n and M_(i)=M_(j)

((j=i)OR(j=(i+r)modN)). The column labels are base vectors of dimensionn.

[0071] Quantum Block:

[0072] The Shor's quantum gate may be described with the quantum circuitof FIG. 6. Shor's quantum gate shown in FIG. 7 is very similar toSimon's quantum gate shown in FIG. 8, unless for the last operator.

[0073] In Simon's algorithm the operator ^(n)H is applied to the first nvectors exiting from U_(F). This operator of the Simon's algorithm isresponsible for the deletion of some of the cells in the first column ofthe final gate and this produces a special superposition of base vectorsas output. By measuring this superposition it is possible to solve theSimon's problem.

[0074] In Shor's algorithm the interference operator is not ^(n)H, infact the main diagonal pattern of U_(F) is different, and therefore adifferent interference operator is needed to extract the information.This operator is represented by the matrix QFT_(n), called QuantumFourier Transform of order n. This operator is non-classical because itmaps a base vector into a complex linear combination of base vectors. Ingeneral, a base vector |i> is mapped into the linear combination α₁y₁+ .. +α₂ _(^(n)) y₂ _(^(n)) where α_(i) and α_(i+1) have the same absolutevalue ½^(n/2) but they are phase shifted i·(2π/2^(n)) starting withα_(i)=½^(n/2). The operator is defined as follows: TABLE 7 Φ=0Φ=2π/2^(n) . . . Φ=(2^(n)−1) 2π/2^(n) QFT_(n) |0 . . . 0> |0 . . . 1> .. . |1 . . . 1> |0 . . . 0> 1/2^(n/2) 1/2^(n/2) . . . 1/2^(n/2) |0 . . .1> 1/2^(n/2) 1/2^(n/2) e^(J2π/2) ^(n) . . . 1/2^(n/2) e^(J(2) ^(n)^(−1)2π/2) ^(n) . . . . . . . . . . . . |1 . . . 1> 1/2^(n/2) 1/2^(n/2)e^(J(2) ^(n) ^(−1)2π/2) ^(n) . . . 1/2^(n/2) e^(J(2) ^(n) ⁻¹⁾ ² ^(2π/2)^(n)

[0075] where J is the imaginary unit. By using the transformation rulesshown in FIGS. 5a to 5 f to the circuit of FIG. 6, the quantum gate ofFIG. 7 is obtained.

[0076] A discussion of the form of these gates for a few particularcases will follow and the observations will then be generalized.

[0077] A. Introductory Example:

[0078] If n=2, the quantum gate has the following form:

G=(QFT₂ {circle over (x)} ² I)·U _(F)·(² H{circle over (x)} ² I)

[0079] This gate is now calculated for the first considered example:TABLE 8 ²H

²I |00> |01> |10> |11> |00> ²I/2 ²I/2 ²I/2 ²I/2 |01> ²I/2 −²I/2 ²I/2−²I/2 |10> ²I/2 ²I/2 −²I/2 −²I/2 |11> ²I/2 −²I/2 −²I/2 ²I/2

[0080] The matrix U_(F) has been already presented in TABLE 4, thereforeTABLE 9 U_(F) (²H

²I) |00> |01> |10> |11> |00> I

C/2 I

C/2 I

C/2 I

C/2 |01> C

C/2 −C

C/2 C

C/2 −C

C/2 |10> I

C/2 I

C/2 −I

C/2 −I

C/2 |11> C

C/2 −C

C/2 −C

C/2 C

C/2

[0081] If n=2, QFT₂ is as follows: TABLE 10 Φ=0 Φ=π/2 Φ=π Φ=3π/2 QFT₂|00> |01> |10> |11> |00> 1/2 1/2 1/2 1/2 |01> 1/2 J/2 −1/2 −J/2 |10> 1/2−1/2 1/2 −1/2 |11> 1/2 −J/2 −1/2 J/2

[0082] TABLE 11 QFT₂

²I |00> |01> |10> |11> |00> ²I/2 ²I/2 ²I/2 ²I/2 |01> ²I/2 J ²I/2 −²I/2−J ²I/2 |10> ²I/2 −²I/2 ²I/2 −²I/2 |11> ²I/2 −J ²I/2 −²I/2 J ²I/2

[0083] The table defining the quantum gate G is calculated as follows:TABLE 12 G |00> |01> |10> |11> |00> (I

C+C

C)/2 (I

C−C

C)/2 0 0 |01> 0 0 (I

C+JC

C)/2 (I

C− JC

C)/2 |10> (I

C−C

C)/2 (I

C+C

C)/2 0 0 |11> 0 0 (I

C−JC

C)/2 (I

C+ JC

C)/2

[0084] By applying the operator G to the vector |0000> the following isobtained:${{{{{{G{0000\rangle}} =}}00}\rangle}\frac{1}{2}( {{I \otimes C} + {C \otimes C}} ){00\rangle}} + {{10\rangle}\frac{1}{2}( {{I \otimes C} - {C \otimes C}} ){{00\rangle}.}}$

[0085] If a measurement of this vector is made and the first two vectorsof dimension 2 are encoded back into their binary labels, the possibleresults are:

[0086] 00 with probability 0.5

[0087] 10 with probability 0.5

[0088] The distance between these values is d=[|10−00|]₁₀[10]₁₀=2, where[s]₁₀ is the decimal representation of the binary string s. It should beobserved that N/r=4/2=2, therefore d=N/r. If r is unknown, it may becalculated as:

r−N/d.

[0089] B. Case with n=2, r=2:

[0090] As shown above, when n=2, the quantum gate has the followingform:

G=(QFT₂ {circle over (x)} ² I)·U_(F)·(² H{circle over (x)} ² I)

[0091] by using the matrices calculated in the introductory example andrecalling U_(F) given by TABLE 5. TABLE 13 U_(F) (²H

²I) |00> |01> |10> |11> |00> M₀₀/2 M₀₀/2 M₀₀/2 M₀₀/2 |01> M₀₁/2 −M₀₁/2M₀₁/2 −M₀₁/2 |10> M₁₀/2 M₁₀/2 −M₁₀/2 −M₁₀/2 |11> M₁₁/2 −M₁₁/2 −M₁₁/2M₁₁/2

[0092] By recalling the expression of the interference operatorQFT₂{circle over (x)}²I shown in TABLE 11, the following generalizedform of G is obtained: TABLE 14 G |00> |01> |10> |11> |00>(M₀₀+M₀₁+M₁₀+M₁₁)/4 (M₀₀−M₀₁+M₁₀−M₁₁)/4 (M₀₀+M₀₁−M₁₀−M₁₁)/4(M₀₀−M₀₁−M₁₀+M₁₁)/4 |01> (M₀₀+JM₀₁−M₁₀−JM₁₁)/4 (M₀₀−JM₀₁−M₁₀+JM₁₁)/4(M₀₀+JM₀₁+M₁₀+JM₁₁)/4 (M₀₀−JM₀₁+M₁₀−JM₁₁)/4 |10> (M₀₀−M₀₁+M₁₀−M₁₁)/4(M₀₀+M₀₁+M₁₀+M₁₁)/4 (M₀₀−M₀₁−M₁₀+M₁₁)/4 (M₀₀+M₀₁−M₁₀−M₁₁)/4 |11>(M₀₀−JM₀₁−M₁₀+JM₁₁)/4 (M₀₀+JM₀₁−M₁₀−JM₁₁)/4 (M₀₀−JM₀₁+M₁₀−JM₁₁)/4(M₀₀+JM₀₁+M₁₀+JM₁₁)/4

[0093] If r=2, like in our introductory example, then M₀₀=M₁₀≠M₀₁=M₁₁.This means: TABLE 15 G |00> |01> |10> |11> |00> (M₀₀+M₀₁)/2 (M₀₀−M₀₁)/20 0 |01> 0 0 (M₀₀+JM₀₁)/2 (M₀₀−JM₀₁)/2 |10> (M₀₀−M₀₁)/2 (M₀₀+M₀₁)/2 0 0|11> 0 0 (M₀₀−JM₀₁)/2 (M₀₀+JM₀₁)/2

[0094] Consider the application of G to vector |0000>:${{{{{{G{0000\rangle}} =}}00}\rangle}\frac{1}{2}( {M_{00} + M_{01}} ){00\rangle}} + {{10\rangle}\frac{1}{2}( {M_{00} - M_{01}} ){{00\rangle}.}}$

[0095] If a measurement is done on this vector and the first two vectorsof dimension 2 are encoded back into their binary labels, then thepossible results are:

[0096] 00 with probability 0.5

[0097] 10 with probability 0.5

[0098] These results that were obtained for our introductory example andthe same conclusions hold.

[0099] C. General Case:

[0100] As already shown, for a general case, the operator U_(F) isdefined as in TABLE 6. The quantum gate G will now be calculated for ageneral situation: TABLE 16 ^(n)H

^(n)I |0 . . . 0> . . . |j> . . . |1 . . . 1> |0 . . . 0> ^(n)I/2^(n/2). . . ^(n)I/2^(n/2) . . . ^(n)I/2^(n/2) |0 . . . 1> ^(n)I/2^(n/2) . . .(−1)^((0...1)·j) . . . −^(n)I/2^(n/2) (^(n)I/2^(n/2)) . . . . . . . . .. . . |i> ^(n)I/2^(n/2) . . . (−1)^(i·j)(^(n)I/2^(n/2)) . . .(−1)^(i·(1...1)) (^(n)I/2^(n/2)) . . . . . . . . . . . . |1 . . . 1>^(n)I/2^(n/2) . . . (−1)^((1...1)·j) . . . (−1)^((1...1)·(1...1))(^(n)I/2^(n/2)) (^(n)I/2^(n/2))

[0101] TABLE 17 UF · (^(n)H

^(n)I) |0 . . . 0> . . . |j> . . . |1 . . . 1> |0 . . . 0>M_(0...0)/2^(n/2) . . . M_(0...0)/2^(n/2) . . . M_(0...0)/2^(n/2) . . .. . . . . . . . . |i> M_(i)/2^(n/2) . . . (−1)^(1·j) M_(i)/2^(n/2) . . .(−1)^(i·(1...1)) M_(i)/2^(n/2) . . . . . . . . . . . . |1 . . . 1>M_(1...1)/2^(n/2) . . . (−1)^((1...1)·j) . . . (−1)^((1...1)·(1...1))M_(1...1)/2^(n/2) M_(1...1)/2^(n/2)

[0102] Observe that:$\lbrack{QFT}\rbrack_{i,j} = {\frac{1}{2^{n/2}}^{{j{\lbrack \rbrack}}_{10}\frac{{{\lbrack j\rbrack}_{10} \cdot 2}\pi}{2^{n}}}}$

[0103] where [i]₁₀ and [j]₁₀ are the decimal representations of thebinary strings i and j. Therefore: TABLE 18 QFT_(n)

^(n)I |0 . . . 0> . . . |j> . . . |1 . . . 1> |0 . . . 0> ^(n)I/2^(n/2). . . ^(n)I/2^(n/2) . . . ^(n)I/2^(n/2) . . . . . . . . . . . . |i>^(n)I/2^(n/2) . . . ^(n)I/2^(n/2)e^(J[i]) ^(₁₀) ^(·[j]) ^(₁₀) ^(2π/2)^(n) . . . ^(n)I/2^(n/2) e^(J[i]) ^(₁₀) ^(·(2) ^(n) ^(−1)2π/2) ^(n) . .. . . . . . . . . . |1 . . . 1> ^(n)I/2^(n/2) . . . ^(n)I/2^(n/2)e^(J(2)^(n) ^(−1)·[j]) ^(₁₀) ^(2π/2) ^(n) . . . ^(n)I/2^(n/2) e^(J(2) ^(n) ⁻¹⁾² ^(2π/2) ^(n)

[0104] The quantum gate G has the following form: TABLE 19 G |0 . . . 0>. . . |0 . . . 0> 1/2^(n)Σ_(k∈{0,1}) _(^(n)) e^(Jπ·0·[k]) ^(₁₀) ^(/2)^(n−1) ⁾ M_(k) . . . . . . . . . |i> 1/2^(n)Σ_(k∈{0,1}) _(^(n))e^(Jπ·[i]) ^(₁₀) ^(·[k]) ^(₁₀) ^(/2) ^(n−1) M_(k) . . . . . . . . . |1 .. . 1> 1/2^(n)Σ_(k∈{0,1}) _(^(n)) e^(Jπ·(2) ^(n) ^(−1)·[k]) ^(₁₀) ^(/2)^(n−1) M_(k) . . .

[0105] Consider the term:

½^(n)Σ_(kε{0,1}) _(^(n)) e^(Jπ·[i]) ^(₁₀) ^(·[k]) ^(₁₀) ^(/2) ^(n−1)M_(k)

[0106] Since M_(i)=P₁{circle over (x)} . . {circle over (x)}P_(n),P_(k)ε{I, C}, k=1, . . , n and M_(i)=M_(j)

((j=i)OR(j=(i+r)modN)) this term may be written as:

½^(n)Σ_(hεR)[e^(Jπ·[i]) ^(₁₀) ^(·[h]) ^(₁₀) ^(/2) ^(n−1) +e^(Jπ·[i])^(₁₀) ^(·[h]) ^(₁₀) ^(+1r)/2) ^(n−1) + . . +e^(Jπ·[i]) ^(₁₀) ^(·([h])^(₁₀) ^(+(l) ^(_(k)) ^(−1)r)/2) ^(n−1) ]M_(h)

or:

½^(n)Σ_(hεR)(−1)^([h]) ^(₁₀) ^([i]) ^(₁₀) ^(/2) ^(n−1) [(−1)^(0r[i])^(₁₀) ^(/2) ^(n−1) +(−1)^(1r[i]) ^(₁₀) ^(/2) ^(n−1) + . . +(−1)^((l)^(_(h)) ^(−1)r[i]) ^(₁₀) ^(/2) ^(n−1) ]M_(h)

[0107] where R={0 . . 0, 0 . . 1, . . , [r−1]₂}. Suppose that N is amultiple of r, then l_(h)=2^(n)/r=1 for every h. Therefore, the previousterm can be transformed into:

½^(n)Σ_(hεR)(−1)^([h]) ^(₁₀) ^([i]) ^(₁₀) ^(/2) ^(n−1) [(−1)^(2·0·[i])^(₁₀) ^(/l)+(−1)^(2·1·[i]) ^(₁₀) ^(/l)+ . . +(−1)^(2·(l−1))·[i] ^(₁₀)^(/l)]M_(h)

[0108] and finally:

½^(n)Σ_(hεR)(−1)^([h]) ^(₁₀) ^([i]) ^(₁₀) ^(/2) ^(n−1) [e^(J·0·(2π[i])^(₁₀) ^(/l))+e^(J·1(2π[i]) ^(₁₀) ^(/l))+ . . +e^(J·(l−1)(2π[i]) ^(₁₀)^(/l))]M_(h)

[0109] The term:

e^(J·0·(2π[i]) ^(₁₀) ^(/l))+e^(J·1·(2π[i]) ^(₁₀) ^(/l))+ . .+e^(J·(l−1)·(2π[i]) ^(₁₀) ^(/l))

[0110] is the summation of the l roots of order of the unity, unless iis a multiple of l. The summation of the roots of a given order of theunity is always null.

[0111] Therefore, in the first column of G, only those cells whose rowlabel is |i> with i multiple of l are non-null. This means that byapplying G to vector |0 . . 0>, measuring the result and encoding backinto their binary values the first n base vectors of dimension 2 in theresulting tensor product, only strings i, such that i=m*l for someinteger m are obtained. This means: i≡0modl.

[0112] Decoder:

[0113] As for Simon's algorithm, the quantum block is repeated severaltimes to build a collection of vectors |i> such that i≡0modl. By puttingthese equations in a system and solving it, the value of l is obtained.Since l=2^(n)/r, r=2^(n)/l is calculated.

[0114] The number of vectors necessary for calculating r depends on thetechnique used for solving the system of equations. In general, it isnecessary to repeat the quantum block for a number of times thatincreases according to a polynomial rule with n.

[0115] If 2^(n) is not a multiple of r, then l_(h)=[2^(n)/r], for somevalues of h, and l_(h)=[2^(n)/r]+1, for some other values of h. The term

e^(J·0(2π[i]) ^(₁₀) ^(/l) ^(_(h)) ⁾+e^(J·1(2π[i]) ^(₁₀) ^(/l) ^(_(h)) ⁾+. . +e^(J·(l) ^(_(h)) ^(−1)(2π[i]) ^(₁₀) ^(/l) ^(_(h)) ⁾

[0116] is not exactly 0 when i is not a multiple of l_(h), although itapproximates 0. Therefore, all possible strings may be found as a resultof measurement, but strings i that do not represent a multiple of2^(n)/r are less likely to be found. To decrease this probability (andincrease the probability of 2^(n)/r-multiples), 2n input bits are usedfor encoding f. This means that more roots of the unity are involved andthus a better approximation is reached.

[0117] According to classic approaches, it is evident that the number ofqubits (quantum bits) of a quantum algorithm may be a critical parameterthat noticeably limits the calculation speed. In fact, by referring tothe scheme of FIG. 6, it may be noticed that by adding only one qubit,the size of matrices with respect to the previous configuration isdoubled and the number of multiplications to be performed growsexponentially. This fact limits the possibility of practically using theShor's and Simon's algorithms when the number n of qubits is relativelylarge.

SUMMARY OF THE INVENTION

[0118] In view of the foregoing background, an object of the presentinvention is to provide a faster method for performing Simon's or Shor'squantum algorithms.

[0119] Differently from known methods, and according to the method ofthe present invention, the superposition matrix operator is notgenerated and row-columns products are not carried out because only theindices of the non-null components of vectors generated by thesuperposition operation are calculated. In doing so, only vectors of2^(n) components need to be calculated and stored, resulting in asignificant savings in terms of computational complexity, time andmemory space.

[0120] More precisely, an object of the invention is to provide a methodfor performing a Simon's or Shor's quantum algorithm over a certainfunction f(x) encoded with a certain number n of qubits, that comprisescarrying out a superposition operation over a set of input vectors andgenerating a superposition vector; carrying out an entanglementoperation and generating a corresponding entanglement vector; andcarrying out an interference operation and generating a correspondingoutput vector.

[0121] The method of the invention carries out the superpositionoperation in a comparably very fast manner because it generates thesuperposition vector by identifying only the non-null components thereofby calculating, as a function of the number n of qubits, the value½^(n/2) of the non-null components of the superposition vector, and bycalculating the indices of these components according to an arithmeticsuccession, the seed of which is 1 and the common difference is 2^(n).According to a preferred embodiment, similar operations are performedalso for simplifying the entanglement operation.

[0122] The method of the invention may be implemented in a correspondingquantum gate that comprises a superposition subsystem carrying out asuperposition operation according to a Simon's or Shor's quantumalgorithm over a set of input vectors, and outputs a superpositionvector. An entanglement subsystem processes components of thesuperposition vector, and outputs a corresponding entanglement vector.An interference subsystem processes components of the entanglementvector, and generates a corresponding output vector.

[0123] A characterizing feature of the quantum gate of the invention isbased upon the superposition subsystem comprising a circuit generating afirst bit string representing the value ½^(n/2) of the non-nullcomponents of the superposition vector and other 2^(n) bit-strings eachrepresenting a respective index of the 2^(n) non-null components of thesuperposition vector. A memory buffer stores the strings representingthe value ½^(n/2) and the indices.

BRIEF DESCRIPTION OF THE DRAWINGS

[0124] The various aspects and advantages of the invention will becomeeven more evident through a detailed description referring to theattached drawings, wherein:

[0125]FIG. 1 is a block diagram of quantum algorithms according to theprior art;

[0126]FIG. 2 is a block diagram of an encoder according to the priorart;

[0127]FIG. 3 is a general structure of the Quantum Block as show in FIG.1;

[0128]FIG. 4 is a circuit for a Deutsch-Jozsa's quantum gate accordingto the prior art;

[0129]FIG. 5a shows an example of tensor product transformationaccording to the prior art;

[0130]FIG. 5b shows an example of dot product transformation accordingto the prior art;

[0131]FIG. 5c shows the identity transformation according to the priorart;

[0132]FIG. 5d shows an example of a propagation rule according to theprior art;

[0133]FIG. 5e shows an example of an iteration rule according to theprior art;

[0134]FIG. 5f explains the input/output tensor rule according to theprior art;

[0135]FIG. 6 illustrates the Shor's quantum algorithm according to theprior art;

[0136]FIG. 7 illustrates the Shor's quantum gate according to thepresent invention; and

[0137]FIG. 8 illustrates the Simon's quantum gate according to thepresent invention.

DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0138] Both for the Shor's algorithm as well as for the Simon'salgorithm, the superposition block is ^(n)H{circle over (x)}^(n)I. Thisimplies that the first n qubits of the input vector are to be multipliedfor ^(n)H and the second n qubits are to be multiplied for ^(n)I.

[0139] To better illustrate how, according to the invention, thesuperposition operation may be greatly simplified, consider thefollowing example with n=3. The first 3 qubits of the vector P generatedby the superposition operator are given by:

H|0>{circle over (x)}H|0>{circle over (x)}H|0>

[0140] Neglecting the constant ½^(3/2) (n=3), this tensor product is:${\begin{bmatrix}1 \\1\end{bmatrix} \otimes \begin{bmatrix}1 \\1\end{bmatrix} \otimes \begin{bmatrix}1 \\1\end{bmatrix}} = \begin{bmatrix}1 & 1 & 1 & 1 & 1 & 1 & 1 & 1\end{bmatrix}^{T}$

[0141] In general the vector P obtained with the superposition operationis

P=└p₁ p₂ . . . p_(2n) ┘

[0142] wherein p_(i)=½^(n/2).

[0143] For the considered example with n=3, this vector P is$P = {\frac{1}{2^{\frac{3}{2}}} \cdot {\begin{bmatrix}1 & 1 & 1 & 1 & 1 & 1 & 1 & 1\end{bmatrix}^{T} \otimes \begin{bmatrix}1 & 0 & 0 & 0 & 0 & 0 & 0 & 0\end{bmatrix}^{T}}}$

[0144] In the general case (any value of n) the components p_(i) of thevector P obtained with the superposition operation according to theShor's or Simon's algorithm are: $\begin{matrix}{p_{i} = \{ \begin{matrix}\frac{1}{2^{n/2}} & {{{if}\quad i} = {1 + {2^{n}( {j - 1} )}}} \\0 & {otherwise}\end{matrix} } & (6)\end{matrix}$

[0145] wherein j=1 . . . 2^(n), i=1 . . . 2^(2n).

[0146] The components of the superposition vector may assume only twovalues, only 2^(n) of which are non-null and must be stored. Anadvantage with respect to the known methods is that it is no longernecessary to store the whole superposition operator ^(n)H{circle over(x)}^(n)I, which has 2^(2n)×2^(2n) components, and performingrow-columns products, but it is possible instead to store only thepositions of the 2^(n) non-null components of the superposition vector.The non-null value of these components is ½^(n/2) and may be calculatedimmediately by knowing the number n of qubits.

[0147] According to the method of the invention, the superpositionvector P is not calculated carrying out 2^(2n) row-column products, asin the known methods, but is determined simply by calculating thepositions of the 2^(n) non-null components, the value of which is½^(n/2). These indices may be easily calculated, for instance in theform of bit strings with a complex programmable logic device (CPLD), bysimply providing the number n of qubits. According to a preferredembodiment of the invention the entanglement operation is also made lesscomplex from a computational point of view than in the known methods.

[0148] It has been noticed that in all quantum algorithms, theentanglement matrix U_(F) is a diagonal block matrix, the structure ofwhich is strictly tied to the binary representation of the function f.The diagonal matrix blocks are chosen from the set formed by theidentity matrix I, the complement matrix C and matrices obtained astensor products thereof.

[0149] For instance, for the Shor's algorithm, with n=2, the diagonalmatrix blocks of the matrix U_(F) are chosen from the set composed of

I{circle over (x)}I, I{circle over (x)}C, C{circle over (x)}I, C{circleover (x)}C

[0150] each having a size 2²×2². These matrix blocks may be immediatelyobtained from TABLE 1 noticing that, if the value 00 corresponds to acertain vector (x₀, x₁), then the matrix block on the diagonal of U_(F)in correspondence of the row |x₀,x₁> is I{circle over (x)}I. Similarly,when f(x₀, x₁) is equal to 01, 10 or 11, the matrix block on thediagonal of U_(F) in correspondence of the row |x₀,x₁> is respectivelyequal to I{circle over (x)}C, C{circle over (x)}I, C{circle over (x)}C.This rule is resumed in the following table: TABLE 20 F(x₀, x₁) = 00F(x₀, x₁) = 01 f(x₀, x₁) = 10 f(x₀, x₁) = 11 I

I I

C C

I C

C

[0151] In general, when this bit-string is known

f(x ₀ , . . . , x _(n−1))=(z ₀ , . . . , z _(m−1))

[0152] it is possible to recognize immediately that the matrix block onthe main diagonal (up-left to down-right) of U_(F) in correspondence ofthe row |x₀, . . . , x_(n−1)> is:

(z₀·C+(1−z₀)·I){circle over (x)} . . . {circle over(x)}(z_(m−1)·C+(1−z_(m−1))·I)

[0153] This straightforward rule may be easily verified and it holds forall quantum algorithms. It allows a quick calculation of the non-null2^(n) matrix blocks of U_(F), each having 2^(n)×2^(n) components.

[0154] By knowing the non-null matrix blocks of the matrix U_(F), it ispossible to quickly calculate the vector A obtained with theentanglement operation, recalling that only a component per each row andper each column of the matrix U_(F) is non-null. According to apreferred embodiment of the method of the invention it is possible tocalculate immediately the components a_(k) of the entanglement vector Awithout calculating any product.

[0155] In more detail, it has been observed that only the first row ofeach 2^(n)×2^(n) matrix block of the entanglement operator U_(F) gives anon-null result, because the non-null components of the superpositionvector P of Shor's and Simon's algorithms are given by eq. (6). As aconsequence, it is even possible to calculate the components a_(k) ofthe entanglement vector A by directly using the following formula$\begin{matrix}{a_{k} = \{ \begin{matrix}\frac{1}{2^{n/2}} & {{{if}\quad k} = {{f(j)} + 1 + {2^{n}( {j - 1} )}}} \\0 & {otherwise}\end{matrix} } & (7)\end{matrix}$

[0156] wherein j=1 . . . 2^(n), k=1 . . . 2^(2n).

[0157] The result is a vector the components of which are null or assumea same non-null value that depends only on the number n of qubits. Asfor the superposition vector, also in this case there are only 2^(n)non-null components having the same value, thus the entanglement vectormay be determined by the indices of the 2^(n) non-null components.

[0158] Therefore, the entanglement operation, as well as thesuperposition operation, may be carried out with a circuit thatgenerates bit-strings that represent these indices and a memory bufferin which to store these strings. It is much more difficult to performthe interference operation of the Shor's algorithm. In fact, differentlyfrom the entanglement operation, the vector components are not composedexclusively by two values. Moreover the presence of tensor products, thenumber of which grows rapidly with n, forms a critical computationalproblem.

[0159] To simplify the input-output relations, certain particularproperties of the matrix QFT_(n){circle over (x)}^(n)I have beenconsidered. Differently from other quantum algorithms, the interferenceoperation in the Shor's algorithm is performed through a quantum Fouriertransformation QFT. As all quantum operators, the QFT operator is aunary operator acting on complex vectors of the Hilbert space. Ittransforms each input vector in a superposition of base vectors of thesame amplitude, but with a phase shift.

[0160] The interference matrix QFT_(n){circle over (x)}^(n)I has only afew non-null components. It has 2^(n)·(2^(n)−1) zeroes in each column.As a consequence, it is not necessary to perform all multiplicationsbecause many of them give a null result.

[0161] Since b_(h) is the components of the vector B generated with theinterference operation, the real part and the imaginary part of b_(h)are given by the following equations:${{Re}\lbrack b_{h} \rbrack} = {\sum\limits_{j = 1}^{2^{n}}{a_{{({h\quad {mod}\quad 2^{n}})} + 1 + {2^{n}{({j - 1})}}}{\cos ( {2\pi \frac{( {j - 1} ) \cdot {{int}\lbrack {( {h - 1} )/2^{n}} \rbrack}}{2^{n}}} )}}}$${{Im}\lbrack b_{h} \rbrack} = {\sum\limits_{j = 1}^{2^{n}}{a_{{({h\quad {mod}\quad 2^{n}})} + 1 + {2^{n}{({j - 1})}}}{\sin ( {2\pi \frac{( {j - 1} ) \cdot {{int}\lbrack {( {h - 1} )/2^{n}} \rbrack}}{2^{n}}} )}}}$

[0162] since int[.] is the function that generates the integer part ofits argument and since h=1 . . 2^(2n).

[0163] Therefore, according to the improved method of the invention,each component is calculated simply by performing a summation of at most2^(n) cosine (or sine) functions and multiplying this summation for½^(n/2), because the non-null components of the entanglement vector Aare equal to ½^(n/2).

[0164] The improvement with respect to the known method is evident,because they contemplate the step of calculating the real and imaginaryparts of the components of the output vector by performing a summationof 2^(2n) products, thus with a significantly greater computationalcomplexity.

That which is claimed is:
 1. A method of performing a Simon's or aShor's quantum algorithm on a given function (f(x)) encoded with acertain number n of qubits, comprising the steps of carrying out asuperposition operation according to one of said quantum algorithms overa set of input vectors, generating a superposition vector (P), carryingout an entanglement operation (U_(F)) on said superposition vector (P),generating a corresponding entanglement vector (A), carrying out aninterference operation on said entanglement vector (A), generating acorresponding output vector (B), and characterized in that saidsuperposition vector (P) is generated through the following processsteps: calculating, in function of said number n of qubits, the value(½^(n/2)) of non null components of said superposition vector (P);calculating indices (i) of the 2^(n) non null components of saidsuperposition vector as an arithmetical succession, the seed of which is1 and the common difference of which is 2^(n) ( i=1+2^(n)(j−1)).
 2. Themethod of claim 1, wherein said entanglement vector is generated throughthe following process steps: calculating indices (k) of the 2^(n) nonnull components of said entanglement vector (A), summing to each term ofsaid arithmetical succession a relative number corresponding to thevalue of the given function (f(j)) calculated in correspondence of thenumber of place (j) of said term in said succession(k=ƒ(j)+1+2^(n)(j−1)); the value of the non null components of saidentanglement vector (A) being equal to that of the superposition vector(P).
 3. The method of claim 2 for carrying out a Shor's quantumalgorithm, comprising the operation of generating real and imaginarycomponents (Re[b_(h)], Im[b_(h)]) of said output vector (B) through thefollowing process steps: for each index h of said real and imaginarycomponents (Re[b_(h)], Im[b_(h)]), veryfying whether among the terms ofthe arithmetic succession hmod2^(n)+1+2^(n)(j−1) of seed hmod2^(n)+1,index j and common difference 2^(n), there is at least a termcorresponding to an index of a non null component of said entanglementvector; if the above test is negative, making said real and imaginarycomponents (Re[b_(h)], Im[b_(h)]) equal to zero, otherwise calculatingsaid real component (Re[b_(h)]) as the product between said value of thenon null components and the summation of the following cosine functions$\cos ( {2\pi \frac{( {j - 1} ) \cdot {{int}\lbrack {( {h - 1} )/2^{n}} \rbrack}}{2^{n}}} )$

and said imaginary component (Im[b_(h)]) as the product between saidvalue of the non null components and the summation of the following sinefunctions$\sin ( {2\pi \frac{( {j - 1} ) \cdot {{int}\lbrack {( {h - 1} )/2^{n}} \rbrack}}{2^{n}}} )$

for all values of said index j of said arithmetical succession to whichcorrespond indices (k) of non null components of said entanglementvector.
 4. A quantum gate for performing a Simon's or a Shor's quantumalgorithm on a given function (f(x)) encoded with a certain number n ofqubits according to the method of claim 1, comprising a superpositionsubsystem carrying out a superposition operation according to one ofsaid quantum algorithms over a set of input vectors, generating asuperposition vector (P), an entanglement subsystem processing saidsuperposition vector (P), generating a corresponding entanglement vector(A), an interference subsystem processing said entanglement vector (A),generating a corresponding output vector (B), and characterized in thatsaid superposition subsystem comprises a circuit generating a first bitstring representing said value (½^(n/2)) of non null components of saidsuperposition vector (P) and other 2^(n) bit-strings each representing arespective index (i) of the 2^(n) non null components of saidsuperposition vector; a memory buffer storing the strings representingsaid value (½^(n/2)) and said indices (i).
 5. The quantum gate of claim4, implementing the method of claim 2, wherein said entanglementsubsystem comprises a circuit generating bit-strings representing saidindices (k) of the 2^(n) non null components of said entanglement vector(A); a second memory buffer storing said bit strings (k).